finalize-staged: Use the core option parsing to load sysroot
authorColin Walters <walters@verbum.org>
Thu, 5 Sep 2019 00:52:15 +0000 (00:52 +0000)
committerColin Walters <walters@verbum.org>
Wed, 11 Dec 2019 14:39:17 +0000 (14:39 +0000)
Prep for using the default mount namespace handling there that
will land as part of the read-only `/sysroot` and `/boot` work.
See https://github.com/ostreedev/ostree/issues/1265

src/ostree/ot-admin-builtin-finalize-staged.c

index 6740f82aa9709134bd81b7ab8aa8fa777970b621..3cea1bdb3e12326161d354ba3d2569fd3dd5c1f6 100644 (file)
 #include "ostree-cmdprivate.h"
 #include "ostree.h"
 
+static GOptionEntry options[] = {
+  { NULL }
+};
+
 /* Called by ostree-finalize-staged.service, and in turn
  * invokes a cmdprivate function inside the shared library.
  */
@@ -46,11 +50,13 @@ ot_admin_builtin_finalize_staged (int argc, char **argv, OstreeCommandInvocation
   if (fstatat (AT_FDCWD, "/run/ostree-booted", &stbuf, 0) < 0)
     return TRUE;
 
-  g_autoptr(GFile) sysroot_file = g_file_new_for_path ("/");
-  g_autoptr(OstreeSysroot) sysroot = ostree_sysroot_new (sysroot_file);
-
-  if (!ostree_sysroot_load (sysroot, cancellable, error))
+  g_autoptr(GOptionContext) context = g_option_context_new ("");
+  g_autoptr(OstreeSysroot) sysroot = NULL;
+  if (!ostree_admin_option_context_parse (context, options, &argc, &argv,
+                                          OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER,
+                                          invocation, &sysroot, cancellable, error))
     return FALSE;
+
   if (!ostree_cmd__private__()->ostree_finalize_staged (sysroot, cancellable, error))
     return FALSE;